<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="物料id" prop="goodsId">
        <el-input
          v-model="queryParams.goodsId"
          placeholder="请输入物料id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="物料类型id" prop="goodsTypeId">
        <el-input
          v-model="queryParams.goodsTypeId"
          placeholder="请输入物料类型id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="价格" prop="price">
        <el-input
          v-model="queryParams.price"
          placeholder="请输入价格"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料名称" prop="goodsName">
        <el-input
          v-model="queryParams.goodsName"
          placeholder="物料名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料简称" prop="goodsShortName">
        <el-input
          v-model="queryParams.goodsShortName"
          placeholder="请输入物料简称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="单位" prop="unit">
        <el-input
          v-model="queryParams.unit"
          placeholder="请输入单位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商id" prop="providerId">
        <el-input
          v-model="queryParams.providerId"
          placeholder="请输入供应商id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="储存区id" prop="storageAreaId">
        <el-input
          v-model="queryParams.storageAreaId"
          placeholder="请输入储存区id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-input
          v-model="queryParams.status"
          placeholder="请输入状态"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="创建时间" prop="createDate">
        <el-date-picker clearable
                        v-model="queryParams.createDate"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择创建时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="修改时间" prop="updateDate">
        <el-date-picker clearable
                        v-model="queryParams.updateDate"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择修改时间">
        </el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:goods:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:goods:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:goods:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:goods:export']"
        >导出
        </el-button>
      </el-col>
<!--      <el-col :span="1.5">-->
<!--        <el-button plain-->
<!--                   icon="el-icon-download" size="mini" @click="resetDateFilter">清除日期过滤器-->
<!--        </el-button>-->
<!--      </el-col>-->
<!--      <el-col :span="1.5">-->
<!--        <el-button plain-->
<!--                   icon="el-icon-download" size="mini" @click="clearFilter">清除所有过滤器-->
<!--        </el-button>-->
<!--      </el-col>-->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

<!--    <el-table ref="filterTable" v-loading="loading" :data="goodsList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column sortable label="编号" align="center" prop="id"/>
      <el-table-column label="物料id" align="center" prop="goodsId"/>
      <el-table-column label="物料名称" align="center" prop="goodsName"/>
      <el-table-column label="物料简称" align="center" prop="goodsShortName"/>
      <el-table-column label="py名称" align="center" prop="pyName"/>
      <el-table-column label="物料类型id" align="center" prop="goodsTypeId"/>
      <el-table-column label="规格" align="center" prop="specification"/>
      <el-table-column label="模型" align="center" prop="model"/>
      <el-table-column label="价格" align="center" prop="price"/>
      <el-table-column label="条形码" align="center" prop="barcode"/>
      <el-table-column label="g长度" align="center" prop="glength"/>
      <el-table-column label="g宽度" align="center" prop="gwidthz"/>
      <el-table-column label="g高" align="center" prop="gheight"/>
      <el-table-column label="g体积" align="center" prop="gvolume"/>
      <el-table-column label="规模单位" align="center" prop="scaleUnit"/>
      <el-table-column label="单位" align="center" prop="unit"/>
      <el-table-column label="警告up" align="center" prop="warnUp"/>
      <el-table-column label="警告dowm" align="center" prop="warnDown"/>
      <el-table-column label="生产区域" align="center" prop="produceArea"/>
      <el-table-column label="总重量" align="center" prop="grossWeight"/>
      <el-table-column label="净重" align="center" prop="netWeight"/>
      <el-table-column label="供应商id" align="center" prop="providerId"/>
      <el-table-column label="hs编号" align="center" prop="hsnumber"/>
      <el-table-column label="abc分类" align="center" prop="abc"/>
      <el-table-column label="危险品" align="center" prop="hazardous"/>
      <el-table-column label="存储方式" align="center" prop="stored"/>
      <el-table-column label="${comment}" align="center" prop="period"/>
      <el-table-column label="${comment}" align="center" prop="periodunit"/>
      <el-table-column label="${comment}" align="center" prop="addtax"/>
      <el-table-column label="${comment}" align="center" prop="season"/>
      <el-table-column label="${comment}" align="center" prop="tariffrate"/>
      <el-table-column label="备注" align="center" prop="remark"/>
      <el-table-column label="状态" align="center" prop="status"/>
      <el-table-column label="${comment}" align="center" prop="version"/>
      <el-table-column label="物料图片" align="center" prop="img"/>
      <el-table-column label="创建人" align="center" prop="createMan"/>
      <el-table-column label="创建时间" align="center" prop="createDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="修改人" align="center" prop="updateMan"/>
      <el-table-column label="修改时间" align="center" prop="updateDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="${comment}" align="center" prop="scFlag"/>
      <el-table-column label="${comment}" align="center" prop="costPrice"/>
      <el-table-column label="${comment}" align="center" prop="isOpen"/>
      <el-table-column label="${comment}" align="center" prop="storageAreaId"/>
      <el-table-column label="${comment}" align="center" prop="zhFlag"/>
      <el-table-column label="${comment}" align="center" prop="semists"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:goods:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:goods:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>-->


    <el-table
      :data="goodsList"
      border
      ref="filterTable" v-loading="loading"
      @selection-change="handleSelectionChange"
      style="width: 100%">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column  sortable fixed  label="编号" align="center" prop="id"/>
      <el-table-column sortable label="物料id" align="center" prop="goodsId"/>
      <el-table-column  label="物料名称" align="center" prop="goodsName"/>
      <el-table-column  label="物料简称" align="center" prop="goodsShortName"/>
      <el-table-column  label="py名称" align="center" prop="pyName"/>
      <el-table-column  sortable label="物料类型id" align="center" prop="goodsTypeId"/>
      <el-table-column  label="规格" align="center" prop="specification"/>
      <el-table-column  label="模型" align="center" prop="model"/>
      <el-table-column  sortable label="价格" align="center" prop="price"/>
      <el-table-column  label="条形码" align="center" prop="barcode"/>
      <el-table-column  sortable label="g长度" align="center" prop="glength"/>
      <el-table-column  sortable label="g宽度" align="center" prop="gwidthz"/>
      <el-table-column  sortable label="g高" align="center" prop="gheight"/>
      <el-table-column  sortable label="g体积" align="center" prop="gvolume"/>
      <el-table-column  label="规模单位" align="center" prop="scaleUnit"/>
      <el-table-column  label="单位" align="center" prop="unit"/>
      <el-table-column  label="警告up" align="center" prop="warnUp"/>
      <el-table-column  label="警告dowm" align="center" prop="warnDown"/>
      <el-table-column  label="生产区域" align="center" prop="produceArea"/>
      <el-table-column  sortable label="总重量" align="center" prop="grossWeight"/>
      <el-table-column  sortable label="净重" align="center" prop="netWeight"/>
      <el-table-column  sortable label="供应商id" align="center" prop="providerId"/>
      <el-table-column  sortable label="hs编号" align="center" prop="hsnumber"/>
      <el-table-column  label="abc分类" align="center" prop="abc"/>
      <el-table-column  label="危险品" align="center" prop="hazardous"/>
      <el-table-column  label="存储方式" align="center" prop="stored"/>
      <el-table-column  sortable label="周期" align="center" prop="period"/>
      <el-table-column  sortable label="时期" align="center" prop="periodunit"/>
      <el-table-column  label="附加税" align="center" prop="addtax"/>
      <el-table-column  label="季节" align="center" prop="season"/>
      <el-table-column  sortable label="关税税率" align="center" prop="tariffrate"/>
      <el-table-column  label="备注" align="center" prop="remark"/>
      <el-table-column  label="状态" align="center" prop="status"/>
      <el-table-column  label="版本" align="center" prop="version"/>
      <el-table-column  label="物料图片" align="center" prop="img"/>
      <el-table-column  label="创建人" align="center" prop="createMan"/>
      <el-table-column   sortable label="创建时间" align="center" prop="createDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column  label="修改人" align="center" prop="updateMan"/>
      <el-table-column   sortable label="修改时间" align="center" prop="updateDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column  label="${comment}" align="center" prop="scFlag"/>
      <el-table-column  sortable label="成本价" align="center" prop="costPrice"/>
      <el-table-column  label="${comment}" align="center" prop="isOpen"/>
      <el-table-column  sortable label="储存区id" align="center" prop="storageAreaId"/>
      <el-table-column  label="${comment}" align="center" prop="zhFlag"/>
      <el-table-column  label="${comment}" align="center" prop="semists"/>

      <el-table-column  fixed="right" label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:goods:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:goods:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改【请填写功能名称】对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row >
          <!-- 每个el-col是一个栅格单元，span="12"表示占据12/24的宽度，即一半 -->
          <el-col :span="12">
            <el-form-item label="物料id"  prop="goodsId">
              <el-input v-model="form.goodsId" placeholder="请输入物料id"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料名称" prop="goodsName">
              <el-input v-model="form.goodsName" type="textarea" placeholder="请输入内容"/>
            </el-form-item>
          </el-col>
        </el-row>
          <!-- 重复上面的模式，为每个表单项添加el-col -->
          <el-row >
          <el-col :span="12">
            <el-form-item label="物料简称" prop="goodsShortName">
              <el-input v-model="form.goodsShortName" placeholder="请输入物料简称"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="py名称" prop="pyName">
              <el-input v-model="form.pyName" placeholder="请输入py名称"/>
            </el-form-item>
          </el-col>
        </el-row>
          <!-- 继续添加其他表单项，每行两个，直到所有表单项都被包含 -->
          <el-row >
          <el-col :span="12">
            <el-form-item label="物料类型id"   prop="goodsTypeId">
              <el-input v-model="form.goodsTypeId" placeholder="请输入物料类型id"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="规格" prop="specification">
              <el-input v-model="form.specification" type="textarea" placeholder="请输入规格"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="模型" prop="model">
              <el-input v-model="form.model" placeholder="请输入模型"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="价格" prop="price">
              <el-input v-model="form.price" type="textarea" placeholder="请输入价格"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="条形码" prop="barcode">
              <el-input v-model="form.barcode" placeholder="请输入条形码"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="长度" prop="glength">
              <el-input v-model="form.glength" type="textarea" placeholder="请输入长度"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="宽度" prop="gwidthz">
              <el-input v-model="form.gwidthz" placeholder="请输入宽度"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="高" prop="gheight">
              <el-input v-model="form.gheight" type="textarea" placeholder="请输入高"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="体积" prop="gvolume">
              <el-input v-model="form.gvolume" placeholder="请输入体积"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="规模单位" prop="scaleUnit">
              <el-input v-model="form.scaleUnit" type="textarea" placeholder="请输入规模单位"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="单位" prop="unit">
              <el-input v-model="form.unit" placeholder="请输入单位"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="警告up" prop="warnUp">
              <el-input v-model="form.warnUp" type="textarea" placeholder="请输入警告up"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="警告dowm" prop="warnDown">
              <el-input v-model="form.warnDown" placeholder="请输入警告dowm"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="生产区域" prop="produceArea">
              <el-input v-model="form.produceArea" type="textarea" placeholder="请输入生产区域"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="总重量" prop="grossWeight">
              <el-input v-model="form.grossWeight" placeholder="请输入总重量"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="净重" prop="netWeight">
              <el-input v-model="form.netWeight" type="textarea" placeholder="请输入净重"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="供应商id" prop="providerId">
              <el-input v-model="form.providerId" placeholder="请输入供应商id"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="hs编号" prop="hsnumber">
              <el-input v-model="form.hsnumber" type="textarea" placeholder="请输入hs编号"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="abc分类" prop="abc">
              <el-input v-model="form.abc" placeholder="请输入abc分类"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="危险品" prop="hazardous">
              <el-input v-model="form.hazardous" type="textarea" placeholder="请输入危险品"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="存储方式" prop="stored">
              <el-input v-model="form.stored" placeholder="请输入存储方式"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="周期" prop="period">
              <el-input v-model="form.period" type="textarea" placeholder="请输入周期"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="时期" prop="periodunit">
              <el-input v-model="form.periodunit" placeholder="请输入时期"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="附加税" prop="addtax">
              <el-input v-model="form.addtax" type="textarea" placeholder="请输入附加税"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="季节" prop="season">
              <el-input v-model="form.season" placeholder="请输入季节"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="关税税率" prop="tariffrate">
              <el-input v-model="form.tariffrate" type="textarea" placeholder="请输入关税税率"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" placeholder="请输入备注"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="状态" prop="status">
              <el-input v-model="form.status" type="textarea" placeholder="请输入状态"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="版本" prop="version">
              <el-input v-model="form.version" placeholder="请输入版本"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料图片" prop="img">
              <el-input v-model="form.img" type="textarea" placeholder="请输入物料图片"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="scFlag" prop="scFlag">
              <el-input v-model="form.scFlag" placeholder="请输入scFlag"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="成本价" prop="costPrice">
              <el-input v-model="form.costPrice" type="textarea" placeholder="请输入成本价"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="isOpen" prop="isOpen">
              <el-input v-model="form.isOpen" placeholder="请输入isOpen"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="储存区id" prop="storageAreaId">
              <el-input v-model="form.storageAreaId" type="textarea" placeholder="请输入储存区id"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="12">
            <el-form-item label="zhFlag" prop="zhFlag">
              <el-input v-model="form.zhFlag" placeholder="请输入zhFlag"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="semists" prop="semists">
              <el-input v-model="form.semists" type="textarea" placeholder="semists"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitForm">确定</el-button>
          <el-button @click="cancel">取消</el-button>
        </div>

    </el-dialog>
  </div>
</template>

<script>
import {listGoods, getGoods, delGoods, addGoods, updateGoods} from "@/api/system/goods";

export default {
  name: "Goods",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      goodsList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        goodsId: null,
        goodsName: null,
        goodsShortName: null,
        pyName: null,
        goodsTypeId: null,
        specification: null,
        model: null,
        price: null,
        barcode: null,
        glength: null,
        gwidthz: null,
        gheight: null,
        gvolume: null,
        scaleUnit: null,
        unit: null,
        warnUp: null,
        warnDown: null,
        produceArea: null,
        grossWeight: null,
        netWeight: null,
        providerId: null,
        hsnumber: null,
        abc: null,
        hazardous: null,
        stored: null,
        period: null,
        periodunit: null,
        addtax: null,
        season: null,
        tariffrate: null,
        status: null,
        version: null,
        img: null,
        createMan: null,
        createDate: null,
        updateMan: null,
        updateDate: null,
        scFlag: null,
        costPrice: null,
        isOpen: null,
        storageAreaId: null,
        zhFlag: null,
        semists: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        goodsId: [
          {required: true, message: "物料id不能为空", trigger: "blur"}
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      listGoods(this.queryParams).then(response => {
        this.goodsList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        goodsId: null,
        goodsName: null,
        goodsShortName: null,
        pyName: null,
        goodsTypeId: null,
        specification: null,
        model: null,
        price: null,
        barcode: null,
        glength: null,
        gwidthz: null,
        gheight: null,
        gvolume: null,
        scaleUnit: null,
        unit: null,
        warnUp: null,
        warnDown: null,
        produceArea: null,
        grossWeight: null,
        netWeight: null,
        providerId: null,
        hsnumber: null,
        abc: null,
        hazardous: null,
        stored: null,
        period: null,
        periodunit: null,
        addtax: null,
        season: null,
        tariffrate: null,
        remark: null,
        status: null,
        version: null,
        img: null,
        createMan: null,
        createDate: null,
        updateMan: null,
        updateDate: null,
        scFlag: null,
        costPrice: null,
        isOpen: null,
        storageAreaId: null,
        zhFlag: null,
        semists: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加【请填写功能名称】";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getGoods(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改【请填写功能名称】";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateGoods(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addGoods(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除【请填写功能名称】编号为"' + ids + '"的数据项？').then(function () {
        return delGoods(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/goods/export', {
        ...this.queryParams
      }, `goods_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
